<template>
  <div class="card">
    <div class="card-header">最新问题</div>
    <div class="card-content card-list">
      <div
        v-for="issue in currentSpace.recentIssues"
        :key="issue.id"
        class="flex card-list-item align-items-center"
      >
        <svg-icon
          :icon-name="issue.solved ? 'issue-solved' : 'issue-open'"
          :style="`color: ${issue.solved ? '#67c23a' : '#e6a23c'};`"
          class="s15 m-r-5"
        />
        <router-link class="flex-1 link no-warp-ellipsis" :title="issue.title"
                     :to="initIssuePath(issue)">{{ issue.title }}</router-link>
        <timeago2 class="shrink-0 m-l-10" :date-time="issue.updated_at"/>
      </div>
    </div>
  </div>
</template>

<script>
import { mapState } from 'vuex';

export default {
  name: 'RecentIssues', // 活跃问题
  computed: {
    ...mapState(['currentSpace']),
  },
  methods: {
    // 生成问题跳转链接
    initIssuePath(issue) {
      const [rp, spaceId] = [this.$rp, this.currentSpace.id];
      return `/${rp.SPACES}/${spaceId}/${rp.SPACE_ISSUES}/${issue.id}`;
    },
  },
};
</script>

<style></style>
